//
//  RightViewController.m
//  微blog
//
//  Created by Jorn.Wu on 15/8/25.
//  Copyright (c) 2015年 Jorn.Wu(jorn_wza@sina.com). All rights reserved.
//

#import "RightViewController.h"
#import "ThemeButton.h"
#import "MMDrawerController.h"
#import "UIViewController+MMDrawerController.h"
#import "BaseNavigationController.h"
#import "SendWeiboViewController.h"
#import "NearbyViewController.h"

@interface RightViewController ()

@end

@implementation RightViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addButtons];
}

- (void)addButtons{
    // 图片的数组
    NSArray *imageNames = @[@"newbar_icon_1.png",
                            @"newbar_icon_2.png",
                            @"newbar_icon_3.png",
                            @"newbar_icon_4.png",
                            @"newbar_icon_5.png"];
    CGFloat w = 40;
    CGFloat h = 40;
    CGFloat x = 20;
    CGFloat s = 10;
    
    for (int i = 0; i < imageNames.count; i++) {
        ThemeButton *btn = [[ThemeButton alloc] initWithFrame:CGRectMake(x, 100 + (h + s) * i, w, h)];
        btn.normalImageName = imageNames[i];
        
        btn.tag = 100 + i;
        [btn addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        
        
        
        
        [self.view addSubview:btn];
    }
    
    
}

- (void)buttonAction:(UIButton *)button{
    if (button.tag == 100) {    //发送微博
        // 发送微博
        [self.mm_drawerController toggleDrawerSide:MMDrawerSideRight animated:YES completion:^(BOOL finished) {     //右边控制器
            // 弹出发送微博控制器
            
            SendWeiboViewController *senderVc = [[SendWeiboViewController alloc] init];
            senderVc.title = @"发送微博";
            
            
            // 创建导航控制器
            BaseNavigationController *baseNav = [[BaseNavigationController alloc] initWithRootViewController:senderVc];
            baseNav.backgroudImageName = @"mask_titlebar64.png";
            baseNav.titlColorName = @"Mask_Title_color";
            baseNav.navigationBar.translucent = NO;
            
            [self.mm_drawerController presentViewController:baseNav animated:YES completion:nil];
        }];
    }else if (button.tag == 104) {      //获取附近商圈
        // 获取附近商圈
        [self.mm_drawerController toggleDrawerSide:MMDrawerSideRight animated:YES completion:^(BOOL finished) {     //右边控制器
            // 弹出附近商圈控制器
            
            NearbyViewController *nearbyVc = [[NearbyViewController alloc] init];
            nearbyVc.title = @"附近商圈";
            
            
            // 创建导航控制器
            BaseNavigationController *baseNav = [[BaseNavigationController alloc] initWithRootViewController:nearbyVc];
            baseNav.backgroudImageName = @"mask_titlebar64.png";
            baseNav.titlColorName = @"Mask_Title_color";
            
            [self.mm_drawerController presentViewController:baseNav animated:YES completion:nil];
        }];
    }
    
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
